package com.puzzlebazar.client.util;


public class BoundInfo {
	private int minX;
	private int maxX;
	private int minY;
	private int maxY;

	/**
	 * Creates default bound information
	 */
	public BoundInfo() {
		minX = 1;
		minY = 1;
		maxX = 99;
		maxY = 99;
	}

	/**
	 * Creates custom bound information. Must be between 1 and 99 (inclusive).
	 * 
	 * @param minX Minimum value for X bound
	 * @param minY Minimum value for Y bound
	 * @param maxX Maximum value for X bound
	 * @param maxY Maximum value for Y bound
	 * @throws Exception
	 */
	public BoundInfo(int minX, int minY, int maxX, int maxY)  {
		super();

		if( minX < 1 ) minX = 1;
		else if( minX > 99 ) minX = 99;
		if( maxX < minX ) maxX = minX;
		else if( maxX > 99 ) maxX = 99;		
		if( minY < 1 ) minY = 1;
		else if( minY > 99 ) minY = 99;
		if( maxY < minY ) maxY = minY;
		else if( maxY > 99 ) maxY = 99;

		this.minX = minX;
		this.minY = minY;
		this.maxX = maxX;
		this.maxY = maxY;
	}

	/**
	 * Checks that the passed x coordinate falls between bounds
	 * 
	 * @param x X coordinate to check
	 * @return True if the coordinate falls between bounds, false otherwise
	 */
	public boolean isValidX( int x ) {
		return ( x >= minX && x <= maxX );
	}

	/**
	 * Checks that the passed y coordinate falls between bounds
	 * 
	 * @param x Y coordinate to check
	 * @return True if the coordinate falls between bounds, false otherwise
	 */
	public boolean isValidY( int y ) {
		return ( y >= minY && y <= maxY );
	}
}
